-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0.5.x] Typescript return type for React Inertia useForm() #110
base: main
Are you sure you want to change the base?
Conversation
Drafting pending review from @timacdonald |
Would it be possible to review this soon? Many thanks. |
I just realized that Inertia wasn't exporting the form props for React. I submitted a pull request to fix that, after which this pull request will work. |
@joelstein, just a heads up that PR is to your personal repository and not the official Inertia project. |
I'll be taking a look at this one soon. |
Good catch! 🤦♂️ Here you go: inertiajs/inertia#2166 |
I believe the required Inertia PR should be released this week. After that I'll start taking a closer look at this one and see if we can get it shipped. |
Perfect, thanks! |
The React Inertia useForm() hook is typed to return
any
, but we can improve this by returningForm<Data>
, similar to the React Vue plugin.However, there's no types.ts file in the
react-inertia
package, though the file exists in thevue-inertia
package.https://github.com/laravel/precognition/tree/main/packages/react-inertia/src
https://github.com/laravel/precognition/tree/main/packages/vue-inertia/src
I copied the types.ts file from vue-inertia, modified it with the correct imports, and updated the useForm() return type.